// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import CollapseTransition from 'element-ui/lib/transitions/collapse-transition';
import 'element-ui/lib/theme-chalk/index.css'
import 'element-ui/lib/theme-chalk/base.css';
import MintUI from 'mint-ui'
import 'mint-ui/lib/style.css'

import App from './App'
import router from './router'
import Vuex from 'vuex'
import VueScroller from 'vue-scroller'
import axios from 'axios'
import base from './base.js'//公共方法
//滚动加载
import '../static/plug/mescroll/mescroll.m.js'
import '../static/plug/mescroll/mescroll.min.css'

// import AMap from 'vue-amap';
// Vue.use(AMap);
// AMap.initAMapApiLoader({
//   key: 'b02674c30e6ee45bdfb3c21d9c0b9c69',
//   plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor']
// })


//图片预览
import gallery from 'img-vuer'
Vue.use(gallery, { 
  swipeThreshold: 15  // default 100 ,new in 0.12.0
})

import Croppa from 'vue-croppa'
import 'vue-croppa/dist/vue-croppa.css'


Vue.use(MintUI)




Vue.use(Vuex)
Vue.use(VueScroller)
Vue.use(base)
Vue.use(Croppa)


Vue.prototype.HOST = '/api'
Vue.prototype.$axios=axios
Vue.config.productionTip = false


export const store = new Vuex.Store({
	state:{
		headTip:'',
		address:'',
		lat:'',
		lng:'',
		trendShowit:true,
		itype:1,
		tipid:[],
		tip:[],
		industry:'',
		industryid:'',
		province:'',
		city:'',
		town:'',
		detail:'',
		cards:[],
		ccards:[],
		allCards:[],
		publicCard:[],
		dis:'',
		frompath:{
			path:'',
			query:''
		},
		newData:[]
	},
	mutations:{
		changeNewData(state,obj){
			state.newData = obj.val
		},
		changeFrompath(state,obj){
			state.frompath.path = obj.path
			state.frompath.query = obj.query
		},
		changeHeadTip(state,obj){
			state.headTip = obj.val
		},
		//地址
		changeAddress(state){
			state.address = state.province+state.city+state.town+state.detail
		},
		//省
		changeProvince(state,obj){
			state.province = obj.val
		},
		//市
		changeCity(state,obj){
			state.city = obj.val
		},
		//县
		changeTown(state,obj){
			state.town = obj.val
		},
		//县
		changeDetail(state,obj){
			state.detail = obj.val
		},
		//经纬度
		changeLat(state,obj){
			state.lat = obj.val
		},
		changeLng(state,obj){
			state.lng = obj.val
		},
		//公司个人
		changeItype(state,obj){
			state.itype = obj.val
		},
		//标签
		changeTip(state,obj){
			state.tip.push(obj.val)
			state.tipid.push(obj.id)
		},
		reTip(state,obj){
			state.tip = obj.val
			state.tipid = obj.id
		},
		delTip(state,obj){
			let index = state.tipid.indexOf(obj.id);  
			state.tip.splice(index,1)
			state.tipid.splice(index,1)
		},
		emptyTip(state){
			state.tip = []
			state.tipid = []
		},
		//标签
		changeIndustry(state,obj){
			state.industry = obj.val
			state.industryid = obj.id
		},
		changeTrendshowit(state,obj){
			state.trendShowit = obj.val
		},
		//我的名帖
		changeCards(state,obj){
			state.cards = obj.val
		},
		//公司名帖
		changeCcards(state,obj){
			state.ccards = obj.val
		},
		//所有名帖
		changeAllCards(state,obj){
			state.allCards = obj.val
		},
		addCards(state,obj){
			if(obj.pval){
				state.cards.unshift(obj.pval)
				state.allCards.unshift(obj.pval)
			}else{
				state.ccards.unshift(obj.cval)
				state.allCards.unshift(obj.cval)
			}
		},
		//要发布的名帖
		changePublicCard(state,obj){
			state.artCard = obj.val;
		},
		//清空名帖
		emptyPublicCard(state){
			state.publicCard = [];
		},
		//改变距离
		changeDis(state,obj){
			state.dis = obj.val;
		}
	}
})

Vue.component(CollapseTransition.name, CollapseTransition)
export let vm = new Vue({
	  el: '#app',
	  store,
	  router,
	  render:h=>h(App)
	})
	
